<?php
/**
 * Created by PhpStorm.
 * User: wem
 * Date: 2017/3/28
 * Time: 11:25
 */

namespace app\member\home;


use app\index\controller\Home;
//require APP_PATH.'mall/common/ZoomTK.php';
class Customerregister extends Home
{
    public function index()
    {
        if($this->request->isAjax())
        {
            $param = $this->request->isPost();
            $result = $this->validate($param, 'Customer.register');
            if(true !== $result){
                // 验证失败 输出错误信息
                $this->error($result);
            }
            // 验证码
            $captcha = $this->request->post('captcha', '');
            $captcha == '' && $this->error('请输入验证码');
            if(!captcha_check($captcha, '', config('captcha'))){
                //验证失败
                $this->error('验证码错误或失效');
            };


        }
        $this->setThemes();
        return $this->fetch();
    }

    /**
     *多模板设置
     */
    protected function setThemes() {
        $module = $this->request->module();
        $themes['mobile'] = config('mobile_themes') ? config('mobile_themes') : 'mobile';
        $themes['pc']     = config('pc_themes') ? config('pc_themes') : 'default';
        $view_path        = isMobile() ? 'template/' . $themes['mobile'] . '/' : 'template/' . $themes['pc'] . '/';
        $this->view->config('view_path', $view_path .  $module . '/')
            ->config('tpl_replace_string',array(
                '__IMG__' =>   '/' . $view_path . 'static/images',
                '__JS__'  =>  '/' . $view_path . 'static/js',
                '__CSS__' =>  '/' . $view_path . 'static/css',
            ));
    }
}